home *** CD-ROM | disk | FTP | other *** search
/ IRIX 6.3 Development Libraries / SGI IRIX 6.3 Development Libraries.iso / dist / dist6.3 / gl_dev.idb / usr / include / gl / TheMacro.h.z / TheMacro.h
C/C++ Source or Header  |  1996-12-06  |  7KB  |  185 lines

  1. #ifndef __GL_THEMACRO_H__
  2. #define __GL_THEMACRO_H__
  3. /**************************************************************************
  4.  *                                      *
  5.  *          Copyright (C) 1984, Silicon Graphics, Inc.          *
  6.  *                                      *
  7.  *  These coded instructions, statements, and computer programs  contain  *
  8.  *  unpublished  proprietary  information of Silicon Graphics, Inc., and  *
  9.  *  are protected by Federal copyright law.  They  may  not be disclosed  *
  10.  *  to  third  parties  or copied or duplicated in any form, in whole or  *
  11.  *  in part, without the prior written consent of Silicon Graphics, Inc.  *
  12.  *                                      *
  13.  **************************************************************************/
  14.  
  15. /*
  16.  * TheMacro.h
  17.  *  - display list manipulation macros
  18.  * 
  19.  * $Revision: 1.24 $
  20.  */
  21.  
  22. #include "cppdefs.h"
  23. #include "dlpers.h"
  24. #include "dlproto.h"
  25. #include "dlsz.h"
  26. #include "objectgl.h"
  27.  
  28. /* must be called with a constant for max_dlsz    */
  29. #define BEGINCOMPILE(max_dlsz)                    \
  30. {                                \
  31.     Int32 temparray[max_dlsz/2+1];   /* save room for retsym */    \
  32.     register Objelem *PC = (Objelem *)temparray;
  33.     
  34. /* can be called with a variable for actual_dlsz */
  35. #define ENDCOMPILE(actual_dlsz)                    \
  36.     gl_compile(actual_dlsz,temparray);                \
  37. }
  38.  
  39. /* add size of composite to display list; use with NONPR definitions */
  40. #define    NONPRCOMPILE(composite_dlsz)                \
  41.     if (!gl_nonprim_checkspace(DLSZ_nonprim+composite_dlsz))    \
  42.     return;                            \
  43.     BEGINCOMPILE(DLSZ_nonprim);                    \
  44.     ADDINTRP(nonprim);                        \
  45.     ADDInt32(DLSZ_nonprim+composite_dlsz);            \
  46.     ENDCOMPILE(DLSZ_nonprim)
  47.     
  48.  
  49. /* 
  50.  * Macros to add things to a display list.
  51.  *
  52.  * ASSERT(sizeof(Objelem) == sizeof(Int16) == sizeof(Uint16))
  53.  */
  54. #ifdef lint
  55. #define    _ADDTYPE(type,x)    (void)TOKENPASTE(LINT_ADD,type)(PC,x)
  56. #else
  57. #define    _ADDTYPE(type,x)    { *(type *)PC = (x); PC+=TOKENPASTE(DLSZ_,type) ; }
  58. #endif
  59. #define ADDInt8(x)        *PC++ = (Int16)(x)
  60. #define ADDUint8(x)        *(Uint16 *)PC++ = (Uint16)(x)
  61. #define ADDChar8(x)        *(Uint16 *)PC++ = (Uint16)(x)
  62. #define ADDInt16(x)        *PC++ = (x)
  63. #define ADDUint16(x)        *(Uint16 *)PC++ = (x)
  64. #define ADDInt32(x)        _ADDTYPE(Int32,x)
  65. #define ADDUint32(x)        _ADDTYPE(Uint32,x)
  66. #define ADDFloat32(x)            _ADDTYPE(Float32,x)
  67. #define ADDUdptr(x)        _ADDTYPE(Udptr,(Udptr)(x))
  68. #define ADDVfptr(x)        _ADDTYPE(Vfptr,(Vfptr)(x))
  69. #define ADDMatrix(x)        { gl_copymatrix4d(PC,x); PC+=DLSZ_Matrix ; }
  70.  
  71. #define ADDConst_Int8(x)    *PC++ = (Int16)(x)
  72. #define ADDConst_Uint8(x)    *(Uint16 *)PC++ = (Uint16)(x)
  73. #define ADDConst_Char8(x)    *(Uint16 *)PC++ = (Uint16)(x)
  74. #define ADDConst_Int16(x)    *PC++ = (x)
  75. #define ADDConst_Uint16(x)    *(Uint16 *)PC++ = (x)
  76. #define ADDConst_Int32(x)    _ADDTYPE(Int32,x)
  77. #define ADDConst_Uint32(x)    _ADDTYPE(Uint32,x)
  78. #define ADDConst_Float32(x)        _ADDTYPE(Float32,x)
  79.  
  80. /* convert Float64 to Float32 when building the display list */
  81. #if defined(ECLIPSE) || defined(CLOVER1) || defined(EXPRESS) || defined(LIGHT) || defined(NEWPORT) || defined(IGLOO)
  82. #define ADDFloat64(x)        ADDFloat32((Float32)(x))
  83. #endif
  84. /*
  85.  * WARNING: the following 2 only work for big-endian Float64s
  86.  */
  87. #if    defined(CLOVER2)
  88. #define ADDFloat64(x)                        \
  89.     _iptr = (Int32 *)&x;                      \
  90.     *(_iptr + 1) &= 0x00000000;                 \
  91.     ADDFloat32((Float32)x)
  92. #endif
  93. #if    defined(STAPUFT)
  94. #define ADDFloat64(x)                        \
  95.     _iptr = (Int32 *)&x;                        \
  96.     *(_iptr + 1) &= 0xE0000000 ;                 \
  97.     ADDFloat32((Float32)x)
  98. #endif
  99. #if    defined(VENICE) /* XXX may not work */
  100. #define ADDFloat64(x)                        \
  101.     _iptr = (Int32 *)&x;                        \
  102.     *(_iptr + 1) &= 0xE0000000 ;                 \
  103.     ADDFloat32((Float32)x)
  104. #endif
  105.  
  106. #define ADDConst_Float64(x)    ADDFloat64(x)
  107.  
  108. /* add the address of the interpreter for <name> */
  109. #define ADDINTRP(name)        _ADDTYPE(Intrpfptr,DL_INTRP_NAME(name))
  110. #if 0
  111. #define ADDINTRP(name)                        \
  112.     *(Intrpfptr *)PC = DL_INTRP_NAME(name); PC+=DLSZ_Intrpfptr
  113. #endif
  114.  
  115. /* used for aligning to word boundaries; use ADDInt16(0xdead) when debugging */
  116. #define ADDFILLER()        ADDInt16(0)    
  117.  
  118. /* used when don't need to fill */
  119. #define NOFILLER()        /* no filler */
  120.  
  121. #define    ADDFILLInt8()       ADDFILLInt16()
  122. #define    ADDFILLUint8()      ADDFILLUint16()
  123. #define    ADDFILLChar8()      ADDFILLUint16()
  124. #define    ADDFILLInt16()      ADDFILLER()
  125. #define    ADDFILLUint16()     ADDFILLER()
  126. #define    ADDFILLInt32()      NOFILLER()
  127. #define    ADDFILLUint32()     NOFILLER()
  128. #define    ADDFILLFloat32()    NOFILLER()
  129. #define    ADDFILLFloat64()    NOFILLER()
  130. #define    ADDFILLUdptr()        NOFILLER()
  131. #define    ADDFILLVfptr()        NOFILLER()
  132. #define    ADDFILLMatrix()     NOFILLER()
  133.  
  134. #define    ADDFILLConst_Int8()       ADDFILLInt16()
  135. #define    ADDFILLConst_Uint8()      ADDFILLUint16()
  136. #define    ADDFILLConst_Char8()      ADDFILLUint16()
  137. #define    ADDFILLConst_Int16()      ADDFILLER()
  138. #define    ADDFILLConst_Uint16()     ADDFILLER()
  139. #define    ADDFILLConst_Int32()      NOFILLER()
  140. #define    ADDFILLConst_Uint32()     NOFILLER()
  141. #define    ADDFILLConst_Float32()    NOFILLER()
  142. #define    ADDFILLConst_Float64()    NOFILLER()
  143.  
  144. #define ADDV2(type,v)        { TOKENPASTE(ADD,type)(v[0]); TOKENPASTE(ADD,type)(v[1]); }
  145. #define ADDV3(type,v)        { TOKENPASTE(ADD,type)(v[0]); TOKENPASTE(ADD,type)(v[1]); TOKENPASTE(ADD,type)(v[2]); }
  146. #define ADDV4(type,v)        { TOKENPASTE(ADD,type)(v[0]); TOKENPASTE(ADD,type)(v[1]); TOKENPASTE(ADD,type)(v[2]); TOKENPASTE(ADD,type)(v[3]); }
  147.  
  148.  
  149. /* 
  150.  * Macros to take things from a display list.
  151.  */
  152. #ifdef lint
  153. #define    _TAKETYPE(type,offset)    (type)TOKENPASTE(LINT_TAKE,type)(PC,offset)
  154. #define    TAKEV(type,offset)    (type *)PC
  155. #else
  156. #define    _TAKETYPE(type,offset)    (*(type *)(PC+(offset)))
  157. #define    TAKEV(type,offset)    ((type *)(PC+(offset)))
  158. #endif
  159. #define TAKEInt8(offset)    _TAKETYPE(Int16,offset)
  160. #define TAKEUint8(offset)    _TAKETYPE(Uint16,offset)
  161. #define TAKEChar8(offset)    _TAKETYPE(Uint16,offset)
  162. #define TAKEInt16(offset)    _TAKETYPE(Int16,offset)
  163. #define TAKEUint16(offset)    _TAKETYPE(Uint16,offset)
  164. #define TAKEInt32(offset)    _TAKETYPE(Int32,offset)
  165. #define TAKEUint32(offset)    _TAKETYPE(Uint32,offset)
  166. #define TAKEFloat32(offset)    _TAKETYPE(Float32,offset)
  167.  
  168. #define TAKEConst_Int8(offset)    _TAKETYPE(Int16,offset)
  169. #define TAKEConst_Uint8(offset)    _TAKETYPE(Uint16,offset)
  170. #define TAKEConst_Char8(offset)    _TAKETYPE(Uint16,offset)
  171. #define TAKEConst_Int16(offset)    _TAKETYPE(Int16,offset)
  172. #define TAKEConst_Uint16(offset)    _TAKETYPE(Uint16,offset)
  173. #define TAKEConst_Int32(offset)    _TAKETYPE(Int32,offset)
  174. #define TAKEConst_Uint32(offset)    _TAKETYPE(Uint32,offset)
  175. #define TAKEConst_Float32(offset)    _TAKETYPE(Float32,offset)
  176.  
  177. /* conversion from Float64 to Float32 done when building the display list */
  178. #define TAKEFloat64(offset)    _TAKETYPE(Float32,offset)
  179.  
  180. #define TAKEUdptr(offset)    _TAKETYPE(Udptr,offset)
  181. #define TAKEVfptr(offset)    _TAKETYPE(Vfptr,offset)
  182. #define    TAKEMatrix(offset)    _TAKETYPE(Matrix,offset)
  183.  
  184. #endif    /* !__GL_THEMACRO_H__ */
  185.